<?php 
include 'method/win.php';

if(!isset($_SESSION['user'])){
    show_msg("请先登录!","login.php");
}
if(isset($_GET['action'])){
    logout();
}
if(isset($_POST['submit'])){
    fixpw($_SESSION['user'], $_POST['telephone'], md5($_POST['password']), md5($_POST['newpw']));
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <link rel="stylesheet" href="../lib/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/fixpw.css">
    <script src="../lib/jquery/jquery.js" type="text/javascript"></script>
    <script src="../lib/bootstrap/js/bootstrap.js" type="text/javascript"></script>
</head>
<body>
<!--顶部导航条-->
<nav class="navbar navbar-default">
    <div class="container-fluid">
        <!--头部logo-->
        <div class="navbar-header">
            <a class="navbar-brand" href="#"><em><img src="../img/logo.jpg" height=30 width=30></em><em>小狗微博</em></a>
        </div>

        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <!--搜索框-->
            <form class="navbar-form navbar-left" role="search" method="post" action="search_loginafter.php">
                <div class="form-group">
                    <input type="text" class="form-control" style="width: 400px" placeholder="Search" name="str-search">
                </div>
                <button type="sumbit" class="btn btn-default" name="search-btn">搜索</button>
            </form>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="index_loginafter.php">首页</a></li>
                <li><a href="person_loginafter.php"><?php echo $_SESSION['user']?></a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">我的消息 <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="inbox.php?page=1">@我</a></li>
                        <li><a href="inbox.php?page=2">评论</a></li>
                        <li><a href="inbox.php?page=3">回复</a></li>
                        <li><a href="inbox.php?page=4">赞</a></li>
                    </ul>
                </li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">个人中心 <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                    	<li><a href="fixpw.php">修改密码</a></li>
                        <li><a href="fixtx.php">修改头像</a></li>
                        <li><a href="index_loginafter.php?action=logout">退出登录</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</nav>

<div class="fixpw-box">
    <form onsubmit="return check()" name="myform" id="myform" method="post" action="">
        <label>修改密码</label>
        <div class="list-mune">
            <i class="glyphicon glyphicon-phone" style="margin-right: 10px"></i>
            <input name="telephone" class="input-telephone" placeholder="请输入注册时的手机号码">
        </div>
        <div class="list-mune">
            <i class="glyphicon glyphicon-lock" style="margin-right: 10px"></i>
            <input name="password" class="input-password" placeholder="请输入原密码">
        </div>
        <div class="list-mune">
            <i class="glyphicon glyphicon-lock" style="margin-right: 10px"></i>
            <input name="newpw" class="input-newpw" placeholder="请输入新密码">
        </div>
        <div class="list-mune">
            <i class="glyphicon glyphicon-lock" style="margin-right: 10px"></i>
            <input name="flgpw" class="input-flgpw" placeholder="请确认新密码">
        </div>
        <div class="btn-list">
            <button type="reset">重置</button>
            <button name="submit" type="submit" style="float: right; margin-right: 20px">确定</button>
        </div>
    </form>
</div>
</body>
<script>
    function check() {
        if($(".input-telephone").val()==""){
            alert("手机号码不能为空");
            return false;
        }
        if($(".input-telephone").val().length !== 11){
            alert("手机号码要为11位哦");
            return false;
        }
        if($(".input-password").val()==""||$(".input-newpw").val()==""||$(".input-flgpw").val()==""){
            alert("密码不能为空");
            return false;
        }
        if($(".input-newpw").val()!=$(".input-flgpw").val()){
            alert("两次输入密码不一致");
            return false;
        }
        if($(".input-newpw").val().length<6 || $(".input-newpw").val().length>10){
            alert("请输入长度大于6位的新密码");
            return false;
        }
    }
</script>
</html>